package fr.afcepf.ticketing.dao;

import java.util.Collection;

import javax.annotation.PostConstruct;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import fr.afcepf.ticketing.domain.OrderLine;

@Stateless
@Local
public class OrderLineJpa extends GenericDaoJpa<OrderLine, Integer> implements
		OrderLineDao {

	@PersistenceContext
	private EntityManager em;

	@PostConstruct
	public void initEntityManagerOfGenericDaoJpa() {
		super.setEntityManager(em);
	}

	@Override
	public Integer createEntity(OrderLine entity) {
		em.persist(entity);
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<OrderLine> getAllOrderLines() {
		return em.createQuery("select ol from OrderLine as ol").getResultList();
	}

	@Override
	public OrderLine getEntityByPk(Integer pk) {
		return em.find(OrderLine.class, pk);
	}



}
